<!DOCTYPE html  >
<html lang="zh">
<head>
<title>订单结算</title>
  <{include file="public/header" /}>
  <style>
    .pay{
      margin-top:unset !important;
      margin-left: 10px;
    }
    .btn-2{
        width: 45%;float: left;
    }
    .btn-3{
        display: flex;
        flex-direction: column;
        margin-top: 10px !important;
    }
    .mg10-0 {
      margin: 10px 0;
      overflow: hidden;
      text-align: center;
    }
  </style>
</head>
<body ontouchstart>
<!--主体-->
<header class="wy-header">
  <div class="wy-header-icon-back"><span></span></div>
  <div class="wy-header-title">订单</div>
</header>
<div class="weui-content">
  <div class="wy-media-box weui-media-box_text address-select">
    <div class="weui-media-box_appmsg">
      <div class="weui-media-box__hd proinfo-txt-l" style="width:20px;"><span class="promotion-label-tit"><img src="/static/mall/images/icon_nav_city.png" /></span></div>
      <div class="weui-media-box__bd">
        <a href=""  class="weui-cell_access addr">
          <h4 class="address-name"><span class="addr-username"></span><span class="addr-mobile"></span></h4>
          <div class="address-txt addr-detail"></div>
        </a>
      </div>
      <div class="weui-media-box__hd proinfo-txt-l" style="width:16px;"><div class="weui-cell_access"><span class="weui-cell__ft"></span></div></div>
    </div>
  </div>
  <div class="wy-media-box weui-media-box_text">
    <div class="weui-media-box__bd">
     <div class="weui-media-box_appmsg ord-pro-list">
        <div class="weui-media-box__hd"><a href="" class="pro-url"><img class="weui-media-box__thumb pro-thumb" src="" alt=""></a></div>
        <div class="weui-media-box__bd">
          <h1 class="weui-media-box__desc"><a href="" class="ord-pro-link pro-name pro-url"></a></h1>
          <p class="weui-media-box__desc"> </p>
          <div class="clear mg-t-10">
            <div class="wy-pro-pri fl">¥<em class="num font-15 pro-price"></em></div>
            <div class="pro-amount fr"><div  class="Spinner" data-spin="spinner"><a class="Decrease " href="javascript:void(0)"><i>-</i></a><input class="Amount count" value="1" autocomplete="off" maxlength="3"><a class="Increase Increase17" href="javascript:void(0)"><i>+</i></a></div></div>
          </div>
        </div>
      </div>
    </div>
  </div>
 <div class="weui-panel">
    <div class="weui-panel__bd">
      <div class="weui-media-box weui-media-box_small-appmsg">
        <div class="weui-cells">
          <div class="weui-cell weui-cell_access">

            <div class="weui-cell__bd weui-cell_primary">
              <p class="font-14"><span class="mg-r-10">配送方式</span><span class="fr send-type">快递</span></p>
            </div>

          </div>
            <div class="weui-cell weui-cell_access tihuo_box" style="display: none">

                <div class="weui-cell__bd weui-cell_primary">
                    <p class="font-14"><span class="mg-r-10">提货地址</span><span class="fr tihuo_address">快递</span></p>
                </div>

            </div>
            <a class="weui-cell weui-cell_access" href="javascript:switchCoupon()">
                <div class="weui-cell__bd weui-cell_primary">
                    <p class="font-14"><span class="mg-r-10">优惠券</span><span class="sitem-tip"><em class="num coupon-count">0</em>张可用<em class="coupon-desc"></em></span></p>
                </div>

                <span class="weui-cell__ft"></span>
            </a>
            <div class="weui-form__control-area coupon-list" style="display: none">
                <div class="weui-cells__group weui-cells__group_form">
                    <div class="weui-cells weui-cells_radio coupon-list-items"></div>
                </div>
            </div>
          <!--<div class="weui-cell weui-cell_access" href="javascript:;">
            <div class="weui-cell__bd weui-cell_primary">
              <p class="font-14"><span class="mg-r-10">运费</span><span class="fr txt-color-red">￥<em class="num">10.00</em></span></p>
            </div>
          </div>
          <a class="weui-cell weui-cell_access" href="money.html">
            <div class="weui-cell__bd weui-cell_primary">
              <p class="font-14"><span class="mg-r-10">可用积分</span><span class="sitem-tip"><em class="num">1235</em>个</span></p>
            </div>
            <span class="weui-cell__ft"></span>
          </a>
-->        </div>
      </div>
    </div>
  </div>

  <div class="wy-media-box weui-media-box_text btn-group-bb">
    <div class="mg10-0 t-c">总金额：<span class="wy-pro-pri mg-tb-5">¥<em class="num font-20 totalMoney">0.00</em></span></div>
    <div class="mg10-0">
        <a href="javascript:create('wechat')" class="weui-btn weui-btn_primary  pay pay-wechat" style="display: none">微信</a>
        <a href="javascript:create('alipay')" class="weui-btn   pay pay-alipay" style="display: none;background-color: #1111e0a8">支付宝</a>
        <a href="javascript:create('credit')" class="weui-btn weui-btn_default pay pay-credit"  style="display: none">余额</a>
        <div id="alipay-form" style="display: none"></div>
    </div>
  </div>
    <div class="wy-media-box weui-media-box_text btn-group-cc " style="display: none">
        <div class="mg10-0 t-c">总金额：<span class="wy-pro-pri mg-tb-5">¥<em class="num font-20 totalMoney">0.00</em></span></div>
        <div class="mg10-0">
            <a href="javascript:void(0) " class="weui-btn weui-btn-area weui-btn_default shop_tel">联系店家</a>
        </div>
    </div>


</div>

<{include file="public/footer" /}>
<{include file="public/weixin_jsapi" /}>
<{include file="public/_info_js" /}>
<script>
    //const vConsole = new VConsole();
    var shoptype = 0;
    shop_config();
    var id = bs_get_param('id');
    let logCode = bs_get_param('logCode');
    var count = 1, order_sn = null, cCount = 0;
    let coupon_code = null;
    if (id) {
        var addr_id = bs_get_param('addr_id');
        getData();
    }

    $(".Decrease,.Increase").on('click', function (e) {

        count = Number($(".count").val());
        var nowCount;
        if ($(this).hasClass('Decrease')) {
            nowCount = count - 1;
        } else {
            nowCount = count + 1;
        }
        if (nowCount <= 0) {
            return $.alert('至少购买一个')
        } else {
            $(".count").val(nowCount)
            count = nowCount;
            //修改数量重置订单
            order_sn = null;
            getData();
        }
    });

    function getData() {
        bs_request("<{:url('/mall/order/ready')}>", {
            id: id,
            addr_id: addr_id,
            count: count,
            logCode: logCode
        }, function (res) {
            if (res.code != 0) {
                return $.alert(res.msg);
            }
            if (!in_array(shoptype, [2, 3])) {
                if (res.data.address) {
                    $(".addr-username").html(res.data.address.username);
                    $(".addr-mobile").html(res.data.address.mobile);
                    $(".addr-detail").html(res.data.address.province + ' ' + res.data.address.city + ' ' + res.data.address.area + ' ' + res.data.address.address);
                    $(".addr").attr('href', "<{:url('/mall/user/address_list')}>?from=info&id=" + id)
                    addr_id = res.data.address.id;
                } else {
                    $(".addr-username").html('<div style="    color: red;margin-top: 20px;font-size: 18px;line-height: 20px;">请先添加地址</div>');
                    $(".addr").attr('href', "<{:url('/mall/user/address_list')}>?from=info&id=" + id)
                }
            } else {
                $(".address-select").hide();
            }

            var goods = res.data.goods_list[0];
            $(".count").val(goods.count);
            $(".pro-price").html(goods.price);
            $(".pro-name").html(goods.title);
            $(".pro-url").attr('href', "<{:url('/mall/goods/detail')}>?id=" + id);
            $(".pro-thumb").attr('src', goods.thumb);
            $(".totalMoney").text(res.data.order.totalMoney);

            //优惠券
            couponItem(res)


        });
    }

    function create(type) {
        return start_pay(type, {
            order_sn: order_sn,
            id: id,
            addr_id: addr_id,
            count: count,
            coupon_code: coupon_code
        });
    }

</script>
</body>
</html>
